<%-- 
    Document   : caballo_carrera
    Created on : 13/11/2009, 02:57:53 PM
    Author     : Eduardo
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="Model.JConexion"%>
<%@page import="java.util.ArrayList" %>
<%@page import="java.util.Iterator" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Añade Caballos a Carreras</title>
    </head>

    <body>
        <form action="<% out.println("http://" + request.getLocalName() + ":" + request.getLocalPort() + "/RoyalMowes/C_RelCarrera"); %>" method="post">
       
        <h1>Agrega caballos a las carreras</h1>
        <hr noshade size="2">
        <br>
        <br>
        <center>
        <table><tr>
                <th align="left">Caballo: </th>
                <td>
                    <select name="ID_Caballo" >
                        <option value="">??</option>
                        <%
                        
                        ArrayList al = new ArrayList();
                        String query = "";
                        String[] dat;
                        query = "SELECT c.Id_Caballo, c.Nombre FROM cat_caballo c WHERE c.activo = 1;";
                        JConexion jc = new JConexion("");
                        al = jc.MySQLArray("MySQLRM", "Consulta", query);
                        Iterator it = al.iterator();
                        int pos = 0;
                        while(it.hasNext()){
                        dat = (String[]) al.get(pos);
                        %>
                        <option value="<% out.println(dat[0]); %>"><% out.println(dat[1]); %></option>
                        <%
                        it.next();
                        pos++;
                        }
                        al.clear();
                        %>                        
                    </select>
                </td>
                </tr><tr>
                    <th align="left">Carrera: </th>
                    <td><select name="ID_Carrera" >
                            <option value="">??</option>
                            <%
                            al = new ArrayList();
                        String[] datc;                        
                        query = " SELECT c.Id_Carrera, c.Descripcion, c.Lim_Inf, c.Lim_Sup FROM cat_carrera c WHERE c.activo = 1;";
                        al = jc.MySQLArray("MySQLRM", "Consulta", query);
                        Iterator itc = al.iterator();
                        pos = 0;
                        while(itc.hasNext()){
                        datc = (String[]) al.get(pos);
                        %>
                        <option value="<% out.println(datc[0]); %>"><% out.println(datc[1]); %></option>
                        <%
                        itc.next();
                        pos++;
                        }
                       
                        %>
                        </select>
                    </td>
                </tr>
              
                <tr>
                    <th align="left">Peso del Caballo: </th>
                    <td><select name="peso">
                            <option value="">??</option>
                            <%
                            pos = 0;
                            datc = (String[]) al.get(1);
                            int i = 0;
                            int li = Integer.parseInt(datc[2]);
                            int ls = Integer.parseInt(datc[3]);
                            for(i=li; i<=ls; i++){ %>
                            <option value="<%=i%>"><%=i%></option>
                            <% }                            
                            pos++;                            
                            %>
                        </select>
                    </td>
                </tr>
               
                <tr>
                    <th align="left">Posicion del Caballo: </th>
                    <td><select name="posicion">
                            <option value="">??</option>
                            <%
                            for(i=1; i<=6; i++){ %>
                            <option value="<%=i%>"><%=i%></option>
                            <%
                            }
                            %>
                        </select>
                    </td>
                </tr><tr>
                    <td colspan="2"><input type="submit" name="registrar" value="Registrar" title="Registra los datos ingresados"></td>
                </tr>
        </table>
        </center>
        </form>
    </body>
</html>
